<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>receiver</title>
</head>
<body>
<p>receiver</p>
<div id="showText" style="width: 200px;height: 300px">
</div>
<input type="text" id="news" value="请输入"/><br/>
<input type="button" value="发送订阅主题" onclick="send()"/>
<input type="button" value="接受指定消息" onclick="receive()"/>
</body>
<script>
    var xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange = callback;
    function send() {
        var doc=document.getElementById("news");
        var x=doc.value;
        if(x==""){
            alert("请在框中输入消息");
            return false;
        }
        myurl="jms/jmsTsend/"+x;
        xmlhttp.open("get",myurl);
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8');
        xmlhttp.send(null);
    }
    function receive() {
        myurl="jms/jmsQget";
        xmlhttp.open("get",myurl);
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8');
        xmlhttp.send(null);
    }
    function callback() {
        if(xmlhttp.readyState==4&&xmlhttp.status==200){
            var c=xmlhttp.responseText;
            var res=document.getElementById("showText");
            if(c!="")
                res.innerHTML=res.innerHTML+"<br/>"+c;
        }
    }
</script>
</html>